import { postRequest } from '@/utils/api'

const $appManageApi = {

  // 页面完成部署配置后进行服务的部署
  deployYaml: param => {
    return postRequest('/gv-kube/appmanage/yaml/deploy', param)
  },

  // 分页获取所有服务实例
  listKubeDeploy: param => {
    return postRequest('/gv-kube/appmanage/yaml/page', param)
  },

  // 从缓存中读取服务实例的状态
  getDeployStatus: param => {
    return postRequest('/gv-kube/appmanage/yaml/status', param)
  },

  // 从缓存中读取服务实例的状态
  getDeployDetail: param => {
    return postRequest(`/gv-kube/appmanage/yaml/detail/${param}`, null)
  },

  // 页面完成配置部署后进行服务的启动
  startYamlDeploy: param => {
    return postRequest(`/gv-kube/appmanage/yaml/start`, param)
  },

  // 对处于运行状态的服务进行停止
  stopYamlDeploy: param => {
    return postRequest(`/gv-kube/appmanage/yaml/stop`, param)
  },

  // 检查服务实例部署名称是否冲突
  checkDeployName: param => {
    return postRequest(`/gv-kube/appmanage/yaml/checkname/${param}`, null)
  },

  // 根据服务标识获取服务实例
  listByNameAndVersion: param => {
    return postRequest(`/gv-kube/appmanage/yaml/list?appName=${param}`, null)
  },

  // 容器服务实例删除
  deleteYamlDeploy: param => {
    return postRequest(`/gv-kube/appmanage/yaml/delete`, param)
  },

  // 获取已部署服务实例的配置
  getDeployConfig: param => {
    return postRequest(`/gv-kube/appmanage/yaml/config/${param}`, null)
  },

  // 获取已部署服务实例的配置
  upgradeYamlDeploy: param => {
    return postRequest(`/gv-kube/appmanage/yaml/upgrade`, param)
  },

  // 获取服务实例所有版本
  rollBackYamlDeploy: param => {
    return postRequest(`/gv-kube/appmanage/version/list/${param}`, null)
  },

  // 容器服务实例回滚
  rollBackYamlDeployByVersion: param => {
    return postRequest(`/gv-kube/appmanage/yaml/rollback?deployId=${param.id}&version=${param.version}`, null)
  },

  // --- 服务组实例相关接口
  // 页面完成部署配置后进行服务组的部署
  createGroupDeploy: param => {
    return postRequest(`/gv-kube/appmanage/group/deploy`, param)
  },

  // 分页获取所有服务组实例
  listGroupDeploy: param => {
    return postRequest(`/gv-kube/appmanage/group/page`, param)
  },

  // 获取服务组下所有服务实例
  listYamlDeploy: param => {
    return postRequest(`/gv-kube/appmanage/group/yaml/list/${param}`)
  },

  // 对部署的服务组实例进行启动
  startGroupDeploy: param => {
    return postRequest(`/gv-kube/appmanage/group/start`, param)
  },

  // 对部署的服务组实例进行停止
  stopGroupDeploy: param => {
    return postRequest(`/gv-kube/appmanage/group/stop`, param)
  },

  // 对部署的服务组实例进行删除
  deleteGroupDeploy: param => {
    return postRequest(`/gv-kube/appmanage/group/delete`, param)
  }
}

export default $appManageApi
